package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.crfOne;
import com.ruoyi.system.service.IcrfOneService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 手术当天，v1，存储患者的试验组Controller
 *
 * @author miao
 * @date 2024-06-30
 */
@RestController
@RequestMapping("/crfOne/crfOne")
public class crfOneController extends BaseController
{
    @Autowired
    private IcrfOneService crfOneService;

    /**
     * 查询手术当天，v1，存储患者的试验组列表
     */
    @ApiOperation("查询手术当天，v1，存储患者的试验组列表")
    @GetMapping("/list")
    public TableDataInfo list(crfOne crfOne)
    {
        List<crfOne> list = crfOneService.selectcrfOneList(crfOne);
        for(crfOne l : list){
            System.out.println("返回l的值是:"+l.getMedicineMethod());
        }
        return getDataTable(list);
    }

    /**
     * 导出手术当天，v1，存储患者的试验组列表
     */
    @ApiOperation("导出手术当天，v1，存储患者的试验组列表")
    @Log(title = "手术当天，v1，存储患者的试验组", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, crfOne crfOne)
    {
        List<crfOne> list = crfOneService.selectcrfOneList(crfOne);
        ExcelUtil<crfOne> util = new ExcelUtil<crfOne>(crfOne.class);
        util.exportExcel(response, list, "手术当天，v1，存储患者的试验组数据");
    }

    /**
     * 获取手术当天，v1，存储患者的试验组详细信息
     */
    @ApiOperation("获取手术当天，v1，存储患者的试验组详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(crfOneService.selectcrfOneById(id));
    }

    /**
     * 新增手术当天，v1，存储患者的试验组
     */
    @ApiOperation("新增手术当天，v1，存储患者的试验组")
    @Log(title = "手术当天，v1，存储患者的试验组", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody crfOne crfOne)
    {
        return toAjax(crfOneService.insertcrfOne(crfOne));
    }

    /**
     * 修改手术当天，v1，存储患者的试验组
     */
    @ApiOperation("修改手术当天，v1，存储患者的试验组")
    @Log(title = "手术当天，v1，存储患者的试验组", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody crfOne crfOne)
    {
        return toAjax(crfOneService.updatecrfOne(crfOne));
    }

    /**
     * 删除手术当天，v1，存储患者的试验组
     */
    @ApiOperation("删除手术当天，v1，存储患者的试验组")
    @Log(title = "手术当天，v1，存储患者的试验组", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(crfOneService.deletecrfOneByIds(ids));
    }

    /**
     * 根据受试者id查询
     */
    @ApiOperation("根据受试者id查询")
    @GetMapping("/list/tid")
    public crfOne selectByTid(int id){
        return crfOneService.selectByTid(id);
    }
}
